package ui.panel
{
	import flash.display.Bitmap;

	import globals.ButtonType;
	import globals.Global;

	import ui.component.GameTextField;
	import ui.component.TextButton;
	import ui.panel.towers.TowerNextInfo;
	import ui.panel.towers.TowerNowInfo;

	import util.TextStyle;
	import util.UIUtil;

	/**
	 * 改建炮塔
	 * @author luguobin
	 */
	public class TowerRebuildPanel extends BasePanel
	{
		private var _nowTowerInfo:TowerNowInfo; //当前的炮塔
		private var _newTowerInfo:TowerNextInfo; //改造成的
		private var _conditionText:GameTextField; //条件
		private var _coinText:GameTextField; //消耗金币
		private var _btn:TextButton;
		private var _img:Bitmap;

		public function TowerRebuildPanel()
		{
			super();
			pid = PanelType.TOWER_REBUILD_PANEL;
			updateTitle("改建炮塔");
		}

		override protected function initUI():void
		{
			super.initUI();

			_nowTowerInfo = new TowerNowInfo();
			_nowTowerInfo.x = 60;
			_nowTowerInfo.y = 50;
			this.addChild(_nowTowerInfo);

			_newTowerInfo = new TowerNextInfo();
			_newTowerInfo.x = 415;
			_newTowerInfo.y = 50;
			this.addChild(_newTowerInfo);

			_img = new Bitmap();
			_img.x = 280;
			_img.y = 80;
			this.addChild(_img);

			_conditionText = new GameTextField();
			_conditionText.defaultTextFormat = TextStyle.getTextFormat();
			_conditionText.wordWrap = _conditionText.multiline = true;
			_conditionText.width = 200;
			_conditionText.x = 250;
			_conditionText.y = 210;
			this.addChild(_conditionText);

			_coinText = new GameTextField();
			_coinText.defaultTextFormat = TextStyle.getTextFormat(0xFFFFFF, 12, true);
			_coinText.x = 250;
			_coinText.y = 300;
			this.addChild(_coinText);

			_btn = UIUtil.getTextButton(0, "改建", ButtonType.BUTTON_BLUE, btnHandle);
			_btn.x = 275;
			_btn.y = 330;
			this.addChild(_btn);

			//TODO：测试
			update();
		}

		private function btnHandle(button:TextButton):void
		{

		}

		public function update():void
		{
			_nowTowerInfo.update();
			_newTowerInfo.update();
			_img.bitmapData = Global.assetsManager.getAssetsAsBitmapData("tower1b");
			_conditionText.htmlText = "改建需求：<br>英雄　好名字的<br>职业　游侠 (已满足)<br>等级　5级 (未满足)";
			_coinText.mytext = "消耗  200";
		}
	}
}